package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 游记
 */
@Setter
@Getter
public class Travel extends BaseDomain{
    public static final int STATE_REJECT = -1;//拒绝
    public static final int STATE_NOMAL = 0;//草稿
    public static final int STATE_WAIT = 1;//待发布
    public static final int STATE_RELEASE = 2;//已发布

    //标题
    private String title;
    //旅游时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date travelTime;
    //人均消费
    private String perExpends;
    //旅游天数
    private Integer days;
    //和谁旅游
    private Integer person;
    //作者
    private User author;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;
    //发布时间
    private Date releaseTime;
    //是否公开
    private Boolean isPublic;
    //地区
    private Region place;
    //封面
    private String coverUrl;
    //最后更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date lastUpdateTime;
    //状态
    private int state;

    //游记内容
    private TravelContent travelContent;
    //游记查看数
    private int showNum;

    //评论数
    private int commentNum;

    //游记内容的点赞数
    private int likeNum = 0;

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        return JSONUtil.toJSONString(map);
    }

}